//
//  DicuessMessageViewController.m
//  OperationPro
//
//  Created by yaxue wang on 16/11/10.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "DicuessMessageViewController.h"
#import "DiscussDetailViewController.h"
#import "DicussMessageTable.h"
#import "InvitationModel.h"
#import "MessageViewController.h"
@interface DicuessMessageViewController ()

@end

@implementation DicuessMessageViewController


- (void)initView
{
    [super initView];
    [self setTitle:@"讨论贴回复"];
    __block typeof(self) blockself = self;
    
    [self.navBar setBackAction:^{
        if([blockself.type isEqualToString:@"推送"]) {
            MessageViewController *messVc=[[MessageViewController alloc]init];
            messVc.type=blockself.type;
            [blockself.navigationController pushViewController:messVc animated:NO];
        }else  {
            [blockself backController];
            
        }
        
    }];
    DicussMessageTable*dicussMessageView =[[DicussMessageTable alloc]initWithFrame:CGRectMake(0, 64, WindowWidth, WindowHeight-64)];
    dicussMessageView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:dicussMessageView];
    
    [dicussMessageView setCCellSelect:^(NSMutableDictionary *dic) {
        DiscussDetailViewController *disscussVC=[[DiscussDetailViewController alloc]init];
        NSString *warn =[dic objectForKey:@"warninguuid"];
        //贴子的uuid
        NSString *uuid=[dic objectForKey:@"uuid"];
        if (warn==nil) {
#pragma mark  贴子的详情
            [blockself setIsLoading:YES];
            [CClass HttpRequestTask:YES withUrl:@"discuss_detail" withData:@{@"uuid":uuid} notifyError:YES onSuccess:^(BaseModel *model) {
                [blockself setIsLoading:NO];
                if (model.B_data==nil) {
                    return ;
                }else
                {
                    disscussVC.invitationModel=[[InvitationModel alloc] initWithDictionary:model.B_data error:nil];
                    disscussVC.isWarnuiud=NO;
                    [blockself pushController:disscussVC];
                }

            } onError:^(BaseModel *model) {
                
            }];
            
        }else
        {
#pragma mark  贴子的详情
            [blockself setIsLoading:YES];
            [CClass HttpRequestTask:YES withUrl:@"discuss_detail" withData:@{@"uuid":uuid} notifyError:YES onSuccess:^(BaseModel *model) {
#pragma mark  保修单的详情
                if (model.B_data==nil) {
                    return ;
                }else
                {
                    
                disscussVC.invitationModel=[[InvitationModel alloc] initWithDictionary:model.B_data error:nil];
                }
                
                [CClass HttpRequestTask:YES withUrl:@"warninglist_orderContent" withData:@{@"warningUuid":warn} notifyError:YES onSuccess:^(BaseModel *model) {
                    [blockself setIsLoading:NO];
                    
                    disscussVC.imageString =[model.B_data objectForKey:@"image"];
                    disscussVC.describe =[model.B_data objectForKey:@"describe"];
                    disscussVC.warnuiud =warn;
                    disscussVC.isWarnuiud=YES;
                    [blockself pushController:disscussVC];
                    
                } onError:^(BaseModel *model) {
                    [blockself setIsLoading:NO];
 
                }];
                
                
            } onError:^(BaseModel *model) {
                [blockself setIsLoading:NO];

            }];
            
        }
        
    }];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
